﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: 02 November 2012 16:44:35
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections;
#if !CF
using System.Runtime.Serialization;
#endif
using System.Data;
using System.Xml.Serialization;
using NetDon.OA.Data;
using NetDon.OA.Data.FactoryClasses;
using NetDon.OA.Data.DaoClasses;
using NetDon.OA.Data.RelationClasses;
using NetDon.OA.Data.HelperClasses;
using NetDon.OA.Data.CollectionClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace NetDon.OA.Data.EntityClasses
{
	
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END

	/// <summary>
	/// Entity class which represents the entity 'Role'. <br/><br/>
	/// 
	/// </summary>
	[Serializable]
	public partial class RoleEntity : CommonEntityBase, ISerializable
		// __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
		// __LLBLGENPRO_USER_CODE_REGION_END	
	{
		#region Class Member Declarations
		private NetDon.OA.Data.CollectionClasses.RoleFunctionCollection	_roleFunction;
		private bool	_alwaysFetchRoleFunction, _alreadyFetchedRoleFunction;
		private NetDon.OA.Data.CollectionClasses.UserRoleCollection	_userRole;
		private bool	_alwaysFetchUserRole, _alreadyFetchedUserRole;
		private NetDon.OA.Data.CollectionClasses.FunctionCollection _functionCollectionViaRoleFunction;
		private bool	_alwaysFetchFunctionCollectionViaRoleFunction, _alreadyFetchedFunctionCollectionViaRoleFunction;
		private NetDon.OA.Data.CollectionClasses.UserCollection _userCollectionViaUserRole;
		private bool	_alwaysFetchUserCollectionViaUserRole, _alreadyFetchedUserCollectionViaUserRole;


		
		// __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region Statics
		private static Dictionary<string, string>	_customProperties;
		private static Dictionary<string, Dictionary<string, string>>	_fieldsCustomProperties;

		/// <summary>All names of fields mapped onto a relation. Usable for in-memory filtering</summary>
		public static partial class MemberNames
		{

			/// <summary>Member name RoleFunction</summary>
			public static readonly string RoleFunction = "RoleFunction";
			/// <summary>Member name UserRole</summary>
			public static readonly string UserRole = "UserRole";
			/// <summary>Member name FunctionCollectionViaRoleFunction</summary>
			public static readonly string FunctionCollectionViaRoleFunction = "FunctionCollectionViaRoleFunction";
			/// <summary>Member name UserCollectionViaUserRole</summary>
			public static readonly string UserCollectionViaUserRole = "UserCollectionViaUserRole";

		}
		#endregion
		
		/// <summary>Static CTor for setting up custom property hashtables. Is executed before the first instance of this entity class or derived classes is constructed. </summary>
		static RoleEntity()
		{
			SetupCustomPropertyHashtables();
		}

		/// <summary>CTor</summary>
		public RoleEntity()
		{
			InitClassEmpty(null);
		}


		/// <summary>CTor</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		public RoleEntity(System.Guid roleId)
		{
			InitClassFetch(roleId, null, null);
		}

		/// <summary>CTor</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		public RoleEntity(System.Guid roleId, IPrefetchPath prefetchPathToUse)
		{
			InitClassFetch(roleId, null, prefetchPathToUse);
		}

		/// <summary>CTor</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <param name="validator">The custom validator object for this RoleEntity</param>
		public RoleEntity(System.Guid roleId, IValidator validator)
		{
			InitClassFetch(roleId, validator, null);
		}


		/// <summary>Private CTor for deserialization</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected RoleEntity(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			_roleFunction = (NetDon.OA.Data.CollectionClasses.RoleFunctionCollection)info.GetValue("_roleFunction", typeof(NetDon.OA.Data.CollectionClasses.RoleFunctionCollection));
			_alwaysFetchRoleFunction = info.GetBoolean("_alwaysFetchRoleFunction");
			_alreadyFetchedRoleFunction = info.GetBoolean("_alreadyFetchedRoleFunction");
			_userRole = (NetDon.OA.Data.CollectionClasses.UserRoleCollection)info.GetValue("_userRole", typeof(NetDon.OA.Data.CollectionClasses.UserRoleCollection));
			_alwaysFetchUserRole = info.GetBoolean("_alwaysFetchUserRole");
			_alreadyFetchedUserRole = info.GetBoolean("_alreadyFetchedUserRole");
			_functionCollectionViaRoleFunction = (NetDon.OA.Data.CollectionClasses.FunctionCollection)info.GetValue("_functionCollectionViaRoleFunction", typeof(NetDon.OA.Data.CollectionClasses.FunctionCollection));
			_alwaysFetchFunctionCollectionViaRoleFunction = info.GetBoolean("_alwaysFetchFunctionCollectionViaRoleFunction");
			_alreadyFetchedFunctionCollectionViaRoleFunction = info.GetBoolean("_alreadyFetchedFunctionCollectionViaRoleFunction");
			_userCollectionViaUserRole = (NetDon.OA.Data.CollectionClasses.UserCollection)info.GetValue("_userCollectionViaUserRole", typeof(NetDon.OA.Data.CollectionClasses.UserCollection));
			_alwaysFetchUserCollectionViaUserRole = info.GetBoolean("_alwaysFetchUserCollectionViaUserRole");
			_alreadyFetchedUserCollectionViaUserRole = info.GetBoolean("_alreadyFetchedUserCollectionViaUserRole");


			base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
			
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
		}

		
		/// <summary>Performs the desync setup when an FK field has been changed. The entity referenced based on the FK field will be dereferenced and sync info will be removed.</summary>
		/// <param name="fieldIndex">The fieldindex.</param>
		protected override void PerformDesyncSetupFKFieldChange(int fieldIndex)
		{
			switch((RoleFieldIndex)fieldIndex)
			{
				default:
					base.PerformDesyncSetupFKFieldChange(fieldIndex);
					break;
			}
		}
		
		/// <summary>Gets the inheritance info provider instance of the project this entity instance is located in. </summary>
		/// <returns>ready to use inheritance info provider instance.</returns>
		protected override IInheritanceInfoProvider GetInheritanceInfoProvider()
		{
			return InheritanceInfoProviderSingleton.GetInstance();
		}
		
		/// <summary> Will perform post-ReadXml actions</summary>
		protected override void PostReadXmlFixups()
		{
			_alreadyFetchedRoleFunction = (_roleFunction.Count > 0);
			_alreadyFetchedUserRole = (_userRole.Count > 0);
			_alreadyFetchedFunctionCollectionViaRoleFunction = (_functionCollectionViaRoleFunction.Count > 0);
			_alreadyFetchedUserCollectionViaUserRole = (_userCollectionViaUserRole.Count > 0);


		}
				
		/// <summary>Gets the relation objects which represent the relation the fieldName specified is mapped on. </summary>
		/// <param name="fieldName">Name of the field mapped onto the relation of which the relation objects have to be obtained.</param>
		/// <returns>RelationCollection with relation object(s) which represent the relation the field is maped on</returns>
		public override RelationCollection GetRelationsForFieldOfType(string fieldName)
		{
			return RoleEntity.GetRelationsForField(fieldName);
		}

		/// <summary>Gets the relation objects which represent the relation the fieldName specified is mapped on. </summary>
		/// <param name="fieldName">Name of the field mapped onto the relation of which the relation objects have to be obtained.</param>
		/// <returns>RelationCollection with relation object(s) which represent the relation the field is maped on</returns>
		public static RelationCollection GetRelationsForField(string fieldName)
		{
			RelationCollection toReturn = new RelationCollection();
			switch(fieldName)
			{

				case "RoleFunction":
					toReturn.Add(RoleEntity.Relations.RoleFunctionEntityUsingRoleId);
					break;
				case "UserRole":
					toReturn.Add(RoleEntity.Relations.UserRoleEntityUsingRoleId);
					break;
				case "FunctionCollectionViaRoleFunction":
					toReturn.Add(RoleEntity.Relations.RoleFunctionEntityUsingRoleId, "RoleEntity__", "RoleFunction_", JoinHint.None);
					toReturn.Add(RoleFunctionEntity.Relations.FunctionEntityUsingFunctionId, "RoleFunction_", string.Empty, JoinHint.None);
					break;
				case "UserCollectionViaUserRole":
					toReturn.Add(RoleEntity.Relations.UserRoleEntityUsingRoleId, "RoleEntity__", "UserRole_", JoinHint.None);
					toReturn.Add(UserRoleEntity.Relations.UserEntityUsingUserId, "UserRole_", string.Empty, JoinHint.None);
					break;

				default:

					break;				
			}
			return toReturn;
		}



		/// <summary> ISerializable member. Does custom serialization so event handlers do not get serialized.
		/// Serializes members of this entity class and uses the base class' implementation to serialize the rest.</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			info.AddValue("_roleFunction", (!this.MarkedForDeletion?_roleFunction:null));
			info.AddValue("_alwaysFetchRoleFunction", _alwaysFetchRoleFunction);
			info.AddValue("_alreadyFetchedRoleFunction", _alreadyFetchedRoleFunction);
			info.AddValue("_userRole", (!this.MarkedForDeletion?_userRole:null));
			info.AddValue("_alwaysFetchUserRole", _alwaysFetchUserRole);
			info.AddValue("_alreadyFetchedUserRole", _alreadyFetchedUserRole);
			info.AddValue("_functionCollectionViaRoleFunction", (!this.MarkedForDeletion?_functionCollectionViaRoleFunction:null));
			info.AddValue("_alwaysFetchFunctionCollectionViaRoleFunction", _alwaysFetchFunctionCollectionViaRoleFunction);
			info.AddValue("_alreadyFetchedFunctionCollectionViaRoleFunction", _alreadyFetchedFunctionCollectionViaRoleFunction);
			info.AddValue("_userCollectionViaUserRole", (!this.MarkedForDeletion?_userCollectionViaUserRole:null));
			info.AddValue("_alwaysFetchUserCollectionViaUserRole", _alwaysFetchUserCollectionViaUserRole);
			info.AddValue("_alreadyFetchedUserCollectionViaUserRole", _alreadyFetchedUserCollectionViaUserRole);


			
			// __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo
			// __LLBLGENPRO_USER_CODE_REGION_END
			base.GetObjectData(info, context);
		}
		
		/// <summary> Sets the related entity property to the entity specified. If the property is a collection, it will add the entity specified to that collection.</summary>
		/// <param name="propertyName">Name of the property.</param>
		/// <param name="entity">Entity to set as an related entity</param>
		/// <remarks>Used by prefetch path logic.</remarks>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntityProperty(string propertyName, IEntity entity)
		{
			switch(propertyName)
			{

				case "RoleFunction":
					_alreadyFetchedRoleFunction = true;
					if(entity!=null)
					{
						this.RoleFunction.Add((RoleFunctionEntity)entity);
					}
					break;
				case "UserRole":
					_alreadyFetchedUserRole = true;
					if(entity!=null)
					{
						this.UserRole.Add((UserRoleEntity)entity);
					}
					break;
				case "FunctionCollectionViaRoleFunction":
					_alreadyFetchedFunctionCollectionViaRoleFunction = true;
					if(entity!=null)
					{
						this.FunctionCollectionViaRoleFunction.Add((FunctionEntity)entity);
					}
					break;
				case "UserCollectionViaUserRole":
					_alreadyFetchedUserCollectionViaUserRole = true;
					if(entity!=null)
					{
						this.UserCollectionViaUserRole.Add((UserEntity)entity);
					}
					break;

				default:

					break;
			}
		}

		/// <summary> Sets the internal parameter related to the fieldname passed to the instance relatedEntity. </summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntity(IEntity relatedEntity, string fieldName)
		{
			switch(fieldName)
			{

				case "RoleFunction":
					_roleFunction.Add((RoleFunctionEntity)relatedEntity);
					break;
				case "UserRole":
					_userRole.Add((UserRoleEntity)relatedEntity);
					break;

				default:

					break;
			}
		}
		
		/// <summary> Unsets the internal parameter related to the fieldname passed to the instance relatedEntity. Reverses the actions taken by SetRelatedEntity() </summary>
		/// <param name="relatedEntity">Instance to unset as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		/// <param name="signalRelatedEntityManyToOne">if set to true it will notify the manytoone side, if applicable.</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void UnsetRelatedEntity(IEntity relatedEntity, string fieldName, bool signalRelatedEntityManyToOne)
		{
			switch(fieldName)
			{

				case "RoleFunction":
					base.PerformRelatedEntityRemoval(_roleFunction, relatedEntity, signalRelatedEntityManyToOne);
					break;
				case "UserRole":
					base.PerformRelatedEntityRemoval(_userRole, relatedEntity, signalRelatedEntityManyToOne);
					break;

				default:

					break;
			}
		}

		/// <summary> Gets a collection of related entities referenced by this entity which depend on this entity (this entity is the PK side of their FK fields). These
		/// entities will have to be persisted after this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override List<IEntity> GetDependingRelatedEntities()
		{
			List<IEntity> toReturn = new List<IEntity>();


			return toReturn;
		}
		
		/// <summary> Gets a collection of related entities referenced by this entity which this entity depends on (this entity is the FK side of their PK fields). These
		/// entities will have to be persisted before this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override List<IEntity> GetDependentRelatedEntities()
		{
			List<IEntity> toReturn = new List<IEntity>();



			return toReturn;
		}
		
		/// <summary> Gets a List of all entity collections stored as member variables in this entity. The contents of the ArrayList is
		/// used by the DataAccessAdapter to perform recursive saves. Only 1:n related collections are returned.</summary>
		/// <returns>Collection with 0 or more IEntityCollection objects, referenced by this entity</returns>
		public override List<IEntityCollection> GetMemberEntityCollections()
		{
			List<IEntityCollection> toReturn = new List<IEntityCollection>();
			toReturn.Add(_roleFunction);
			toReturn.Add(_userRole);

			return toReturn;
		}

		

		

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Guid roleId)
		{
			return FetchUsingPK(roleId, null, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Guid roleId, IPrefetchPath prefetchPathToUse)
		{
			return FetchUsingPK(roleId, prefetchPathToUse, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Guid roleId, IPrefetchPath prefetchPathToUse, Context contextToUse)
		{
			return Fetch(roleId, prefetchPathToUse, contextToUse, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <param name="excludedIncludedFields">The list of IEntityField objects which have to be excluded or included for the fetch. 
		/// If null or empty, all fields are fetched (default). If an instance of ExcludeIncludeFieldsList is passed in and its ExcludeContainedFields property
		/// is set to false, the fields contained in excludedIncludedFields are kept in the query, the rest of the fields in the query are excluded.</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Guid roleId, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
		{
			return Fetch(roleId, prefetchPathToUse, contextToUse, excludedIncludedFields);
		}

		/// <summary> Refetches the Entity from the persistent storage. Refetch is used to re-load an Entity which is marked "Out-of-sync", due to a save action. 
		/// Refetching an empty Entity has no effect. </summary>
		/// <returns>true if Refetch succeeded, false otherwise</returns>
		public override bool Refetch()
		{
			return Fetch(this.RoleId, null, null, null);
		}

		/// <summary> Returns true if the original value for the field with the fieldIndex passed in, read from the persistent storage was NULL, false otherwise.
		/// Should not be used for testing if the current value is NULL, use <see cref="TestCurrentFieldValueForNull"/> for that.</summary>
		/// <param name="fieldIndex">Index of the field to test if that field was NULL in the persistent storage</param>
		/// <returns>true if the field with the passed in index was NULL in the persistent storage, false otherwise</returns>
		public bool TestOriginalFieldValueForNull(RoleFieldIndex fieldIndex)
		{
			return base.Fields[(int)fieldIndex].IsNull;
		}
		
		/// <summary>Returns true if the current value for the field with the fieldIndex passed in represents null/not defined, false otherwise.
		/// Should not be used for testing if the original value (read from the db) is NULL</summary>
		/// <param name="fieldIndex">Index of the field to test if its currentvalue is null/undefined</param>
		/// <returns>true if the field's value isn't defined yet, false otherwise</returns>
		public bool TestCurrentFieldValueForNull(RoleFieldIndex fieldIndex)
		{
			return base.CheckIfCurrentFieldValueIsNull((int)fieldIndex);
		}

				
		/// <summary>Gets a list of all the EntityRelation objects the type of this instance has.</summary>
		/// <returns>A list of all the EntityRelation objects the type of this instance has. Hierarchy relations are excluded.</returns>
		public override List<IEntityRelation> GetAllRelations()
		{
			return new RoleRelations().GetAllRelations();
		}


		/// <summary> Retrieves all related entities of type 'RoleFunctionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'RoleFunctionEntity'</returns>
		public NetDon.OA.Data.CollectionClasses.RoleFunctionCollection GetMultiRoleFunction(bool forceFetch)
		{
			return GetMultiRoleFunction(forceFetch, _roleFunction.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'RoleFunctionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'RoleFunctionEntity'</returns>
		public NetDon.OA.Data.CollectionClasses.RoleFunctionCollection GetMultiRoleFunction(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiRoleFunction(forceFetch, _roleFunction.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'RoleFunctionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public NetDon.OA.Data.CollectionClasses.RoleFunctionCollection GetMultiRoleFunction(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiRoleFunction(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'RoleFunctionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual NetDon.OA.Data.CollectionClasses.RoleFunctionCollection GetMultiRoleFunction(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedRoleFunction || forceFetch || _alwaysFetchRoleFunction) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_roleFunction.ParticipatesInTransaction)
					{
						base.Transaction.Add(_roleFunction);
					}
				}
				_roleFunction.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_roleFunction.EntityFactoryToUse = entityFactoryToUse;
				}
				_roleFunction.GetMultiManyToOne(null, this, filter);
				_roleFunction.SuppressClearInGetMulti=false;
				_alreadyFetchedRoleFunction = true;
			}
			return _roleFunction;
		}

		/// <summary> Sets the collection parameters for the collection for 'RoleFunction'. These settings will be taken into account
		/// when the property RoleFunction is requested or GetMultiRoleFunction is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersRoleFunction(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_roleFunction.SortClauses=sortClauses;
			_roleFunction.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'UserRoleEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'UserRoleEntity'</returns>
		public NetDon.OA.Data.CollectionClasses.UserRoleCollection GetMultiUserRole(bool forceFetch)
		{
			return GetMultiUserRole(forceFetch, _userRole.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'UserRoleEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'UserRoleEntity'</returns>
		public NetDon.OA.Data.CollectionClasses.UserRoleCollection GetMultiUserRole(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiUserRole(forceFetch, _userRole.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'UserRoleEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public NetDon.OA.Data.CollectionClasses.UserRoleCollection GetMultiUserRole(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiUserRole(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'UserRoleEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual NetDon.OA.Data.CollectionClasses.UserRoleCollection GetMultiUserRole(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedUserRole || forceFetch || _alwaysFetchUserRole) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_userRole.ParticipatesInTransaction)
					{
						base.Transaction.Add(_userRole);
					}
				}
				_userRole.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_userRole.EntityFactoryToUse = entityFactoryToUse;
				}
				_userRole.GetMultiManyToOne(this, null, filter);
				_userRole.SuppressClearInGetMulti=false;
				_alreadyFetchedUserRole = true;
			}
			return _userRole;
		}

		/// <summary> Sets the collection parameters for the collection for 'UserRole'. These settings will be taken into account
		/// when the property UserRole is requested or GetMultiUserRole is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersUserRole(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_userRole.SortClauses=sortClauses;
			_userRole.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'FunctionEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'FunctionEntity'</returns>
		public NetDon.OA.Data.CollectionClasses.FunctionCollection GetMultiFunctionCollectionViaRoleFunction(bool forceFetch)
		{
			return GetMultiFunctionCollectionViaRoleFunction(forceFetch, _functionCollectionViaRoleFunction.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'FunctionEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public NetDon.OA.Data.CollectionClasses.FunctionCollection GetMultiFunctionCollectionViaRoleFunction(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedFunctionCollectionViaRoleFunction || forceFetch || _alwaysFetchFunctionCollectionViaRoleFunction) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_functionCollectionViaRoleFunction.ParticipatesInTransaction)
					{
						base.Transaction.Add(_functionCollectionViaRoleFunction);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(RoleFields.RoleId, ComparisonOperator.Equal, this.RoleId, "RoleEntity__"));
				_functionCollectionViaRoleFunction.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_functionCollectionViaRoleFunction.EntityFactoryToUse = entityFactoryToUse;
				}
				_functionCollectionViaRoleFunction.GetMulti(filter, GetRelationsForField("FunctionCollectionViaRoleFunction"));
				_functionCollectionViaRoleFunction.SuppressClearInGetMulti=false;
				_alreadyFetchedFunctionCollectionViaRoleFunction = true;
			}
			return _functionCollectionViaRoleFunction;
		}

		/// <summary> Sets the collection parameters for the collection for 'FunctionCollectionViaRoleFunction'. These settings will be taken into account
		/// when the property FunctionCollectionViaRoleFunction is requested or GetMultiFunctionCollectionViaRoleFunction is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersFunctionCollectionViaRoleFunction(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_functionCollectionViaRoleFunction.SortClauses=sortClauses;
			_functionCollectionViaRoleFunction.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'UserEntity'</returns>
		public NetDon.OA.Data.CollectionClasses.UserCollection GetMultiUserCollectionViaUserRole(bool forceFetch)
		{
			return GetMultiUserCollectionViaUserRole(forceFetch, _userCollectionViaUserRole.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public NetDon.OA.Data.CollectionClasses.UserCollection GetMultiUserCollectionViaUserRole(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedUserCollectionViaUserRole || forceFetch || _alwaysFetchUserCollectionViaUserRole) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_userCollectionViaUserRole.ParticipatesInTransaction)
					{
						base.Transaction.Add(_userCollectionViaUserRole);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(RoleFields.RoleId, ComparisonOperator.Equal, this.RoleId, "RoleEntity__"));
				_userCollectionViaUserRole.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_userCollectionViaUserRole.EntityFactoryToUse = entityFactoryToUse;
				}
				_userCollectionViaUserRole.GetMulti(filter, GetRelationsForField("UserCollectionViaUserRole"));
				_userCollectionViaUserRole.SuppressClearInGetMulti=false;
				_alreadyFetchedUserCollectionViaUserRole = true;
			}
			return _userCollectionViaUserRole;
		}

		/// <summary> Sets the collection parameters for the collection for 'UserCollectionViaUserRole'. These settings will be taken into account
		/// when the property UserCollectionViaUserRole is requested or GetMultiUserCollectionViaUserRole is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersUserCollectionViaUserRole(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_userCollectionViaUserRole.SortClauses=sortClauses;
			_userCollectionViaUserRole.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}



		/// <summary> Performs the insert action of a new Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool InsertEntity()
		{
			RoleDAO dao = (RoleDAO)CreateDAOInstance();
			return dao.AddNew(base.Fields, base.Transaction);
		}
		
		/// <summary> Adds the internals to the active context. </summary>
		protected override void AddInternalsToContext()
		{
			_roleFunction.ActiveContext = base.ActiveContext;
			_userRole.ActiveContext = base.ActiveContext;
			_functionCollectionViaRoleFunction.ActiveContext = base.ActiveContext;
			_userCollectionViaUserRole.ActiveContext = base.ActiveContext;



		}


		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity()
		{
			RoleDAO dao = (RoleDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction);
		}
		
		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query</param>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity(IPredicate updateRestriction)
		{
			RoleDAO dao = (RoleDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction, updateRestriction);
		}
	
		/// <summary> Initializes the class with empty data, as if it is a new Entity.</summary>
		/// <param name="validatorToUse">Validator to use.</param>
		protected virtual void InitClassEmpty(IValidator validatorToUse)
		{
			OnInitializing();
			base.Fields = CreateFields();
			base.IsNew=true;
			base.Validator = validatorToUse;

			InitClassMembers();
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}
		
		/// <summary>Creates entity fields object for this entity. Used in constructor to setup this entity in a polymorphic scenario.</summary>
		protected virtual IEntityFields CreateFields()
		{
			return EntityFieldsFactory.CreateEntityFieldsObject(NetDon.OA.Data.EntityType.RoleEntity);
		}
		
		/// <summary>Creates a new transaction object</summary>
		/// <param name="levelOfIsolation">The level of isolation.</param>
		/// <param name="name">The name.</param>
		protected override ITransaction CreateTransaction( IsolationLevel levelOfIsolation, string name )
		{
			return new Transaction(levelOfIsolation, name);
		}

		/// <summary>
		/// Creates the ITypeDefaultValue instance used to provide default values for value types which aren't of type nullable(of T)
		/// </summary>
		/// <returns></returns>
		protected override ITypeDefaultValue CreateTypeDefaultValueProvider()
		{
			return new TypeDefaultValue();
		}

		/// <summary>
		/// Gets all related data objects, stored by name. The name is the field name mapped onto the relation for that particular data element. 
		/// </summary>
		/// <returns>Dictionary with per name the related referenced data element, which can be an entity collection or an entity or null</returns>
		public override Dictionary<string, object> GetRelatedData()
		{
			Dictionary<string, object> toReturn = new Dictionary<string, object>();

			toReturn.Add("RoleFunction", _roleFunction);
			toReturn.Add("UserRole", _userRole);
			toReturn.Add("FunctionCollectionViaRoleFunction", _functionCollectionViaRoleFunction);
			toReturn.Add("UserCollectionViaUserRole", _userCollectionViaUserRole);

			return toReturn;
		}
		

		/// <summary> Initializes the the entity and fetches the data related to the entity in this entity.</summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <param name="validator">The validator object for this RoleEntity</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		protected virtual void InitClassFetch(System.Guid roleId, IValidator validator, IPrefetchPath prefetchPathToUse)
		{
			OnInitializing();
			base.Validator = validator;
			InitClassMembers();
			base.Fields = CreateFields();
			bool wasSuccesful = Fetch(roleId, prefetchPathToUse, null, null);
			base.IsNew = !wasSuccesful;

			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassFetch
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}

		/// <summary> Initializes the class members</summary>
		private void InitClassMembers()
		{
			_roleFunction = new NetDon.OA.Data.CollectionClasses.RoleFunctionCollection(new RoleFunctionEntityFactory());
			_roleFunction.SetContainingEntityInfo(this, "Role");
			_alwaysFetchRoleFunction = false;
			_alreadyFetchedRoleFunction = false;
			_userRole = new NetDon.OA.Data.CollectionClasses.UserRoleCollection(new UserRoleEntityFactory());
			_userRole.SetContainingEntityInfo(this, "Role");
			_alwaysFetchUserRole = false;
			_alreadyFetchedUserRole = false;
			_functionCollectionViaRoleFunction = new NetDon.OA.Data.CollectionClasses.FunctionCollection(new FunctionEntityFactory());
			_alwaysFetchFunctionCollectionViaRoleFunction = false;
			_alreadyFetchedFunctionCollectionViaRoleFunction = false;
			_userCollectionViaUserRole = new NetDon.OA.Data.CollectionClasses.UserCollection(new UserEntityFactory());
			_alwaysFetchUserCollectionViaUserRole = false;
			_alreadyFetchedUserCollectionViaUserRole = false;



			PerformDependencyInjection();
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
			// __LLBLGENPRO_USER_CODE_REGION_END
			OnInitClassMembersComplete();
		}

		#region Custom Property Hashtable Setup
		/// <summary> Initializes the hashtables for the entity type and entity field custom properties. </summary>
		private static void SetupCustomPropertyHashtables()
		{
			_customProperties = new Dictionary<string, string>();
			_fieldsCustomProperties = new Dictionary<string, Dictionary<string, string>>();

			Dictionary<string, string> fieldHashtable = null;
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("RoleId", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("RoleName", fieldHashtable);
		}
		#endregion




		/// <summary> Fetches the entity from the persistent storage. Fetch simply reads the entity into an EntityFields object. </summary>
		/// <param name="roleId">PK value for Role which data should be fetched into this Role object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <param name="excludedIncludedFields">The list of IEntityField objects which have to be excluded or included for the fetch. 
		/// If null or empty, all fields are fetched (default). If an instance of ExcludeIncludeFieldsList is passed in and its ExcludeContainedFields property
		/// is set to false, the fields contained in excludedIncludedFields are kept in the query, the rest of the fields in the query are excluded.</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		private bool Fetch(System.Guid roleId, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
		{
			try
			{
				OnFetch();
				IDao dao = this.CreateDAOInstance();
				base.Fields[(int)RoleFieldIndex.RoleId].ForcedCurrentValueWrite(roleId);
				dao.FetchExisting(this, base.Transaction, prefetchPathToUse, contextToUse, excludedIncludedFields);
				return (base.Fields.State == EntityState.Fetched);
			}
			finally
			{
				OnFetchComplete();
			}
		}


		/// <summary> Creates the DAO instance for this type</summary>
		/// <returns></returns>
		protected override IDao CreateDAOInstance()
		{
			return DAOFactory.CreateRoleDAO();
		}
		
		/// <summary> Creates the entity factory for this type.</summary>
		/// <returns></returns>
		protected override IEntityFactory CreateEntityFactory()
		{
			return new RoleEntityFactory();
		}

		#region Class Property Declarations
		/// <summary> The relations object holding all relations of this entity with other entity classes.</summary>
		public  static RoleRelations Relations
		{
			get	{ return new RoleRelations(); }
		}
		
		/// <summary> The custom properties for this entity type.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Dictionary<string, string> CustomProperties
		{
			get { return _customProperties;}
		}


		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'RoleFunction' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathRoleFunction
		{
			get
			{
				return new PrefetchPathElement(new NetDon.OA.Data.CollectionClasses.RoleFunctionCollection(),
					(IEntityRelation)GetRelationsForField("RoleFunction")[0], (int)NetDon.OA.Data.EntityType.RoleEntity, (int)NetDon.OA.Data.EntityType.RoleFunctionEntity, 0, null, null, null, "RoleFunction", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'UserRole' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUserRole
		{
			get
			{
				return new PrefetchPathElement(new NetDon.OA.Data.CollectionClasses.UserRoleCollection(),
					(IEntityRelation)GetRelationsForField("UserRole")[0], (int)NetDon.OA.Data.EntityType.RoleEntity, (int)NetDon.OA.Data.EntityType.UserRoleEntity, 0, null, null, null, "UserRole", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Function' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathFunctionCollectionViaRoleFunction
		{
			get
			{
				IEntityRelation intermediateRelation = RoleEntity.Relations.RoleFunctionEntityUsingRoleId;
				intermediateRelation.SetAliases(string.Empty, "RoleFunction_");
				return new PrefetchPathElement(new NetDon.OA.Data.CollectionClasses.FunctionCollection(), intermediateRelation,
					(int)NetDon.OA.Data.EntityType.RoleEntity, (int)NetDon.OA.Data.EntityType.FunctionEntity, 0, null, null, GetRelationsForField("FunctionCollectionViaRoleFunction"), "FunctionCollectionViaRoleFunction", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'User' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUserCollectionViaUserRole
		{
			get
			{
				IEntityRelation intermediateRelation = RoleEntity.Relations.UserRoleEntityUsingRoleId;
				intermediateRelation.SetAliases(string.Empty, "UserRole_");
				return new PrefetchPathElement(new NetDon.OA.Data.CollectionClasses.UserCollection(), intermediateRelation,
					(int)NetDon.OA.Data.EntityType.RoleEntity, (int)NetDon.OA.Data.EntityType.UserEntity, 0, null, null, GetRelationsForField("UserCollectionViaUserRole"), "UserCollectionViaUserRole", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}



		/// <summary>Returns the full name for this entity, which is important for the DAO to find back persistence info for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override string LLBLGenProEntityName
		{
			get { return "RoleEntity";}
		}

		/// <summary> The custom properties for the type of this entity instance.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public override Dictionary<string, string> CustomPropertiesOfType
		{
			get { return RoleEntity.CustomProperties;}
		}

		/// <summary> The custom properties for the fields of this entity type. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Dictionary<string, Dictionary<string, string>> FieldsCustomProperties
		{
			get { return _fieldsCustomProperties;}
		}

		/// <summary> The custom properties for the fields of the type of this entity instance. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public override Dictionary<string, Dictionary<string, string>> FieldsCustomPropertiesOfType
		{
			get { return RoleEntity.FieldsCustomProperties;}
		}

		/// <summary> The RoleId property of the Entity Role<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Role"."RoleID"<br/>
		/// Table field type characteristics (type, precision, scale, length): UniqueIdentifier, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, true, false</remarks>
		public virtual System.Guid RoleId
		{
			get { return (System.Guid)GetValue((int)RoleFieldIndex.RoleId, true); }
			set	{ SetValue((int)RoleFieldIndex.RoleId, value, true); }
		}
		/// <summary> The RoleName property of the Entity Role<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Role"."RoleName"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String RoleName
		{
			get { return (System.String)GetValue((int)RoleFieldIndex.RoleName, true); }
			set	{ SetValue((int)RoleFieldIndex.RoleName, value, true); }
		}

		/// <summary> Retrieves all related entities of type 'RoleFunctionEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiRoleFunction()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual NetDon.OA.Data.CollectionClasses.RoleFunctionCollection RoleFunction
		{
			get	{ return GetMultiRoleFunction(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for RoleFunction. When set to true, RoleFunction is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time RoleFunction is accessed. You can always execute
		/// a forced fetch by calling GetMultiRoleFunction(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchRoleFunction
		{
			get	{ return _alwaysFetchRoleFunction; }
			set	{ _alwaysFetchRoleFunction = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property RoleFunction already has been fetched. Setting this property to false when RoleFunction has been fetched
		/// will clear the RoleFunction collection well. Setting this property to true while RoleFunction hasn't been fetched disables lazy loading for RoleFunction</summary>
		[Browsable(false)]
		public bool AlreadyFetchedRoleFunction
		{
			get { return _alreadyFetchedRoleFunction;}
			set 
			{
				if(_alreadyFetchedRoleFunction && !value && (_roleFunction != null))
				{
					_roleFunction.Clear();
				}
				_alreadyFetchedRoleFunction = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'UserRoleEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiUserRole()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual NetDon.OA.Data.CollectionClasses.UserRoleCollection UserRole
		{
			get	{ return GetMultiUserRole(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for UserRole. When set to true, UserRole is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time UserRole is accessed. You can always execute
		/// a forced fetch by calling GetMultiUserRole(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUserRole
		{
			get	{ return _alwaysFetchUserRole; }
			set	{ _alwaysFetchUserRole = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property UserRole already has been fetched. Setting this property to false when UserRole has been fetched
		/// will clear the UserRole collection well. Setting this property to true while UserRole hasn't been fetched disables lazy loading for UserRole</summary>
		[Browsable(false)]
		public bool AlreadyFetchedUserRole
		{
			get { return _alreadyFetchedUserRole;}
			set 
			{
				if(_alreadyFetchedUserRole && !value && (_userRole != null))
				{
					_userRole.Clear();
				}
				_alreadyFetchedUserRole = value;
			}
		}

		/// <summary> Retrieves all related entities of type 'FunctionEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiFunctionCollectionViaRoleFunction()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual NetDon.OA.Data.CollectionClasses.FunctionCollection FunctionCollectionViaRoleFunction
		{
			get { return GetMultiFunctionCollectionViaRoleFunction(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for FunctionCollectionViaRoleFunction. When set to true, FunctionCollectionViaRoleFunction is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time FunctionCollectionViaRoleFunction is accessed. You can always execute
		/// a forced fetch by calling GetMultiFunctionCollectionViaRoleFunction(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchFunctionCollectionViaRoleFunction
		{
			get	{ return _alwaysFetchFunctionCollectionViaRoleFunction; }
			set	{ _alwaysFetchFunctionCollectionViaRoleFunction = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property FunctionCollectionViaRoleFunction already has been fetched. Setting this property to false when FunctionCollectionViaRoleFunction has been fetched
		/// will clear the FunctionCollectionViaRoleFunction collection well. Setting this property to true while FunctionCollectionViaRoleFunction hasn't been fetched disables lazy loading for FunctionCollectionViaRoleFunction</summary>
		[Browsable(false)]
		public bool AlreadyFetchedFunctionCollectionViaRoleFunction
		{
			get { return _alreadyFetchedFunctionCollectionViaRoleFunction;}
			set 
			{
				if(_alreadyFetchedFunctionCollectionViaRoleFunction && !value && (_functionCollectionViaRoleFunction != null))
				{
					_functionCollectionViaRoleFunction.Clear();
				}
				_alreadyFetchedFunctionCollectionViaRoleFunction = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiUserCollectionViaUserRole()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual NetDon.OA.Data.CollectionClasses.UserCollection UserCollectionViaUserRole
		{
			get { return GetMultiUserCollectionViaUserRole(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for UserCollectionViaUserRole. When set to true, UserCollectionViaUserRole is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time UserCollectionViaUserRole is accessed. You can always execute
		/// a forced fetch by calling GetMultiUserCollectionViaUserRole(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUserCollectionViaUserRole
		{
			get	{ return _alwaysFetchUserCollectionViaUserRole; }
			set	{ _alwaysFetchUserCollectionViaUserRole = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property UserCollectionViaUserRole already has been fetched. Setting this property to false when UserCollectionViaUserRole has been fetched
		/// will clear the UserCollectionViaUserRole collection well. Setting this property to true while UserCollectionViaUserRole hasn't been fetched disables lazy loading for UserCollectionViaUserRole</summary>
		[Browsable(false)]
		public bool AlreadyFetchedUserCollectionViaUserRole
		{
			get { return _alreadyFetchedUserCollectionViaUserRole;}
			set 
			{
				if(_alreadyFetchedUserCollectionViaUserRole && !value && (_userCollectionViaUserRole != null))
				{
					_userCollectionViaUserRole.Clear();
				}
				_alreadyFetchedUserCollectionViaUserRole = value;
			}
		}




		/// <summary> Gets or sets a value indicating whether this entity is a subtype</summary>
		protected override bool LLBLGenProIsSubType
		{
			get { return false;}
		}

		/// <summary> Gets the type of the hierarchy this entity is in. </summary>
		[System.ComponentModel.Browsable(false), XmlIgnore]
		protected override InheritanceHierarchyType LLBLGenProIsInHierarchyOfType
		{
			get { return InheritanceHierarchyType.None;}
		}
		
		/// <summary>Returns the NetDon.OA.Data.EntityType enum value for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override int LLBLGenProEntityTypeValue 
		{ 
			get { return (int)NetDon.OA.Data.EntityType.RoleEntity; }
		}
		#endregion


		#region Custom Entity code
		
		// __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region Included code

		#endregion
	}
}
